<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>

    <style>
        li {
            border: 1px dashed black;
            margin: 5px;
        }
        
        li:hover {
            background-color: pink;
            transition: all 0.3s ease;
        }
        
        .v-enter {
            opacity: 0;
            padding-left: 20%;
        }
        
        .v-enter-to {
            opacity: 1;
            padding-left: 0%;
        }
        
        .v-enter-active {
            transition: all 2s ease;
        }
    </style>
</head>
<!-- 
bug1:如注释
2.列表过渡要用transition-group
3.key是必要的。。。。
-->

<body>

    <div id="a">
        <div>
            Id <input type="text" v-model='id'> name
            <input type="text" v-model='name'>
            <input type="button" value="提交" @click='ok'>
        </div>

        <!-- <ul> -->
        <!-- appear实现刚入场的效果， tag设置把transition渲染成什么元素，默认渲染成span-->
        <transition-group appear tag='ul'>
            <li v-for='it in list' :key='it.id'>{{it.id}}----{{it.name}}
                <td>{{it.name}}</td>
            </li>
        </transition-group>
        <!-- </ul> -->



    </div>

    <script>
        var a = new Vue({
            el: '#a ',
            data: {
                id: '',
                name: '',
                list: [{
                    id: 1,
                    name: 'a'
                }, {
                    id: 2,
                    name: 'b'
                }, {
                    id: 3,
                    name: 'c'
                }]
            },
            methods: {
                ok: function() {
                    // this.list.push({
                    //     this.id,
                    //     this.name
                    // });这个错了，正确的是下面的
                    this.list.push({
                        id: this.id,
                        name: this.name
                    })

                }
            }


        })
    </script>
</body>

</html>

</html>